Public Class Frm_SelectContractItem
    Private _Contractitem As String
    Public Property Contractitem() As String
        Get
            Return _Contractitem
        End Get
        Set(ByVal value As String)
            _Contractitem = value
        End Set
    End Property
    Public mtable As New DataTable



    Private Sub Frm_SelectContractItem_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        loadData()
    End Sub

    Private Sub loadData()
        Dim sql As String = "select * from Pur_POD"
        mtable = ReturnDataTable(sql)
        Me.LstboxItem.DataSource = mtable
        Me.LstboxItem.DisplayMember = "fdescribe"
        Me.LstboxItem.ValueMember = "fcode"
    End Sub

    Private Sub LstboxItem_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles LstboxItem.DoubleClick
        If Me.LstboxItem.Text.Length = 0 Then
            Exit Sub
        End If
        If Me.LstboxItem.SelectedValue Is Nothing Then
            Exit Sub
        End If

        Dim fcode As String = Me.LstboxItem.SelectedValue
        Dim rows() As DataRow = mtable.Select("fcode='" & fcode & "'")
        If rows.Length > 0 Then
            For Each mrow As DataRow In rows
                Me.TxtCode.Text = mrow("fcode")
                Me.TxtDescribe.Text = mrow("fdescribe")
                Me.Txtcontent.Text = mrow("fcontent")
            Next
        End If
    End Sub

    Private Sub BtnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOk.Click
        Contractitem = Me.Txtcontent.Text
        Me.Close()
        Me.Dispose()
    End Sub
End Class


